<?php
    @include_once("conn.php");

    $obj = array();

    $user = $_POST["user"];

    if(!$user){
        $obj["status"] = false;
        $obj["detail"] = "请输入完整的参数";
        exit(json_encode($obj));
    }

    $sql = "select * from `userinfo` where user = '$user'";

    $result = mysqli_query($conn,$sql);

    $item = mysqli_fetch_assoc($result);

    if(!$item){
        $obj["status"] = true;
        $obj["detail"] = "用户名可以使用";
    }else{
        $obj["status"] = false;
        $obj["detail"] = "用户名已注册";
    }
    echo json_encode($obj);
?>